/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package progressions;

/**
 *
 * @author Matrix
 */
class Progression {

    protected long first, cur;

    Progression() {
        first = cur = 0;
    }

    protected long firstValue() {
        cur = first;
        return cur;
    }

    protected long nextValue() {
        return ++cur;
    }

    public void printProgres(int n) {
        System.out.print(firstValue());
        for (int i = 2; i <= n; i++) {
            System.out.print(" " + nextValue());
        }
        System.out.println();
    }
}

class AriphmProgression extends Progression {

    protected long inc;

    public AriphmProgression() {
        this(1);
    }

    public AriphmProgression(long inc) {
        this.inc = inc;
    }

    @Override
    protected long nextValue() {
        cur += inc;
        return cur;
    }
}

class GeomProgression extends Progression{

    protected long multiplier;

    public GeomProgression() {
        this(2);
    }

    public GeomProgression(long multiplier) {
        this.multiplier = multiplier;
        cur = first = 1;
    }

    @Override
    protected long nextValue() {
        cur *= multiplier;
        return cur;
    }
}

class FibbonachiProgres extends Progression {

    protected long prev;

    public FibbonachiProgres() {
        this(0, 1);
    }

    public FibbonachiProgres(long first, long next) {
        this.first = first;
        prev = next - first;
    }

    @Override
    protected long nextValue() {
        long temp = prev;
        prev = cur;
        cur += temp;
        return cur;
    }

}

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Progression base = new Progression();
        base.printProgres(25);
        AriphmProgression baseA = new AriphmProgression(2);
        baseA.printProgres(25);
        GeomProgression baseB = new GeomProgression(3);
        baseB.printProgres(25);
        FibbonachiProgres baseF = new FibbonachiProgres(2, 8);
        baseF.printProgres(25);
    }

}
